VERSION = 1.5
SUBDIRS = test

srcdir = .

#### package, host, target, and site dependent Makefile fragments come in here.
##

DIST_NAME = socket++-$(VERSION)
DIST_FILE = $(DIST_NAME).tar.gz
${DIST_FILE}: dist_gz
.PHONY: dist_gz
dist_gz: dist_dir
	tar -chf - $(DIST_NAME) | gzip -c > $(DIST_FILE)
	rm -rf $(DIST_NAME)

.PHONY: dist_shar
dist_shar: dist_dir
	$(SHAR) -osocket++ -l20 $(DIST_NAME)
	rm -rf $(DIST_NAME)

.PHONY: dist_dir
dist_dir: FORCE
	-mkdir $(DIST_NAME)
	cd $(DIST_NAME); \
	  ln -s ../* .; \
	  rm -rf test $(DIST_NAME) *.o *.a *~ *.old \#* \
	      Makefile CVS configure.in socket++.[01]* $(DIST_FILE) ; \
	  sed -e 's|\.\./\.\./||' < ../configure.in > configure.in; \
	  mkdir test
	cd test; make clean
	cd $(DIST_NAME)/test; \
	  ln -s ../../test/* .; \
	  rm -rf *~ *.o *.out *.a \#* *.old Makefile CVS configure.in; \
	  sed -e 's|\.\./\.\./||' < ../../test/configure.in > configure.in

SOCKETXX_HFILES  = sockstream.h sockinet.h sockunix.h pipestream.h

SOCKETXX_CFILES = sockstream.C sockinet.C sockunix.C pipestream.C

SOCKETXX_FILES = $(SOCKET_HFILES) $(SOCKET_CFILES) Makefile

SOCKETXX_OBJECTS = sockstream.o sockinet.o sockunix.o pipestream.o

DEPEND_SOURCES = $(srcdir)/*.C

$(TARGETLIB): $(SOCKETXX_OBJECTS)
	-rm -f $(TARGETLIB)
	$(AR) $(AR_FLAGS) $(TARGETLIB) $(SOCKETXX_OBJECTS)
	$(RANLIB) $(TARGETLIB)

install:
	-parent=`echo $(libdir)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(libdir) ] ; then true ; else mkdir $(libdir) ; fi
	-rm -f $(libdir)/$(TARGETLIB)
	$(INSTALL_DATA) $(TARGETLIB) $(libdir)/$(TARGETLIB)
	$(RANLIB) $(libdir)/$(TARGETLIB)
	-if [ -d $(includedir) ]; then true; else mkdir $(includedir); fi
	$(INSTALL_DATA) $(SOCKETXX_HFILES) $(includedir)

makedepend:
	makedepend $(CXXINCLUDES) $(DEPEND_SOURCES)

FORCE:

# maintainance stuff
update-version:
	for i in $(SOCKETXX_FILES) socket++.texi README; \
		do \
		sed -e "s/Version: [0-9a-zA-Z]* [0-9.]*/Version: `date +%d%h%y` $(VERSION)/g" $$i > TMP$$i; \
		mv TMP$$i $$i; \
		done

TO = gs4t@virginia.edu

sendshar: dist_shar
	test/tsendfiles $(TO) socket++.??

